import book.BookList;
import users.AdminUser;
import users.NormalUser;
import users.User;

import java.util.Scanner;

public class Main {
    public static User login() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的姓名：");
        String name = scanner.nextLine();
        int choice = 0;
        do {
            System.out.println("请选择你的身份： 1：管理员  2：普通用户");
            choice = scanner.nextInt();
            if(choice == 1) {
                return new AdminUser(name);
            }else if(choice == 2){
                return new NormalUser(name);
            }else {
                System.out.println("选择错误，请重新选择（1 or 2）");
            }
        }while(choice != 1 || choice != 2);
        return null;
    }

    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = login();
        while(true) {
            int ret = user.menu();
            user.doWork(ret,bookList);
        }
    }
}
